package edu.map.aamas.gui;

import javax.swing.JSlider;

public class FloatJSlider extends JSlider{

	private static final long serialVersionUID = 1L;
	static final float FLOAT_MINIMUM = 0.0f;
	static final float FLOAT_MAXIMUM = 100.0f;
	static final float FLOAT_MIDDLE = 50.0f;
	static final int PRECISION_MULTIPLIER  = 100;

	public FloatJSlider(){
		super();
		setFloatMinimum(FLOAT_MINIMUM);
		setFloatMaximum(FLOAT_MAXIMUM);
		setFloatValue(FLOAT_MIDDLE);
	}

	public FloatJSlider(float min, float max, float val){
		super();
		setFloatMinimum(min);
		setFloatMaximum(max);
		setFloatValue(val);
	}

	public float getFloatMaximum() {
		return( getMaximum()/FLOAT_MAXIMUM );
	}

	public float getFloatMinimum() {
		return( getMinimum()/FLOAT_MAXIMUM );
	}

	public float getFloatValue() {
		return( getValue()/FLOAT_MAXIMUM );
	}

	public void setFloatMaximum(float max) {
		setMaximum((int)(max*PRECISION_MULTIPLIER));
	}

	public void setFloatMinimum(float min) {
		setMinimum((int)(min*PRECISION_MULTIPLIER));
	}

	public void setFloatValue(float val) {
		setValue((int)(val*PRECISION_MULTIPLIER));
		setToolTipText(Float.toString(val));
	}

}
